package Practice12;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;

public class HashMapTest {
    public static void main(String[] args) {
        LinkedHashMap<Student,String> map = new LinkedHashMap<Student,String>();
        map.put(new Student("lisi",234),"beijing");
        map.put(new Student("lisi1",2314),"12");
        map.put(new Student("lisi2",2324),"be4124ijing");
        map.put(new Student("lisi3",2334),"bei241jing");
        map.put(new Student("lisi4",2534),"bei214jing");
        map.put(new Student("lisi5",2344),"bei51jing");

        // 取出元素，键找值方式
//        如果要保证map中存放的key和取出的顺序一致，可以使用java.util.LinkedHashMap集合来存放。

        Set<Student> keySet = map.keySet();

        for (Student student : keySet) {
            String stu = map.get(student);
            System.out.println(stu);
        }

    }
}
